import Vue from "vue";
import VueRouter from "vue-router";
import Login from "../views/Login.vue";
import Upload from "../views/Upload.vue";
import Home from "../views/Home.vue";
import User from "../views/User.vue";
import Logistics from "../views/Logistics.vue";
import Logistics1 from "../views/Logistics1.vue";
import Logistics2 from "../views/Logistics2.vue";
import Logistics3 from "../views/Logistics3.vue";
import Logistics4 from "../views/Logistics4.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Login",
    component: Login,
  },
  {
    path: "/home",
    name: "Home",
    component: Home,
    redirect: { name: "User" },
    children: [
      {
        path: "/user",
        name: "User",
        component: User,
      },
      {
        path: "/upload",
        name: "Upload",
        component: Upload,
      },
      {
        path: "/Logistics",
        name: "Logistics",
        component: Logistics,
      },
      {
        path: "/Logistics1",
        name: "Logistics1",
        component: Logistics1,
      },
      {
        path: "/Logistics2",
        name: "Logistics2",
        component: Logistics2,
      },
      {
        path: "/Logistics3",
        name: "Logistics3",
        component: Logistics3,
      },
      {
        path: "/Logistics4",
        name: "Logistics4",
        component: Logistics4,
      },
    ],
  },
];
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
